// subpages1/settingPage/settingPage.js
//获取应用实例
const app = getApp()
Page({
  data: {
  
  },
  onLoad: function (e) {
    var that = this;
    that.setData({
      slient: app.globalData.slient
    })
  },
  //重新授权
  againAuthorize:function(e){
    var that = this;
    var again = true;
    app.wechatSq(that, again);
    // console.log(e);
    // if (e.detail.userInfo) {
    //   var userInfo = e.detail.userInfo;
    //   console.log(userInfo);
    //   app.globalData.getuserInfo = userInfo;
    //   app.wechatSq(that,again);
    // }
  },

  // 获取用户信息
  getuserInfo: function (e) {
    var that = this;
    if (e.detail.userInfo) {
      var userdata = e.detail;
      console.log(userdata);
      var slient = that.data.slient;
      var again = false;
      if (slient == 0) {
        again = true;
      }
      app.getuserInfo(that, userdata, again);
    }
  },
  initPage(){

  },
  //打开授权设置页面
  openAuthorize:function(){
    var that = this;
    var again = true;
    app.openSetting(again);
  },
  //清除缓存
  clearstorage:function(){
    var that = this;
    try {
      wx.clearStorageSync();
      wx.showLoading({
        title: '清除中',
      });
      setTimeout(function () { 
        wx.hideLoading();
        wx.showToast({
          title: '清理完成',
          icon: 'success',
          duration: 2000
        })
      }, 500)

    } catch (e) {
      // Do something when catch error
    }
  },
})